import { useState, useEffect } from 'react';

export default function Counter() {
    const [count, setCount] = useState(10);

    useEffect(() => {
        const timer = setInterval(() => {
            console.log('Current count:', count);
            // setCount(count - 1)
            setCount(pre => {
                if (pre === 0) {
                    window.location.href = '/new-path';
                }
                return pre - 1
            })

        }, 1000);

        return () => clearInterval(timer);
    }, []);

    return <div>此页面已废弃: {count} s后将为您自动跳转</div>

}
